'use strict';

const user = require("./info");

module.exports = app => {
    const {
        STRING,
        INTEGER
    } = app.Sequelize;

    const Video = app.model.define('video', {
        id: {
            type: INTEGER,
            primaryKey: true,
            autoIncrement: true
        },
        publisher_id: INTEGER,
        tag_id: INTEGER,
        play_count: INTEGER,
        zan_count: INTEGER,
        name: STRING(100),
        video_img: STRING(200),
        video_src: STRING(500),
    });

    Video.associate = function () {
        app.model.Video.belongsTo(app.model.Info, {
            foreignKey: 'publisher_id',
            targetKey: 'user_id',
            as:'publisher'
        });
    }

    return Video;
};